package org.hackystat.ui.projectviewer.gwt.junit;

import static org.hackystat.telemetry.service.server.ServerProperties.DAILYPROJECTDATA_FULLHOST_KEY;
import static org.hackystat.telemetry.service.server.ServerProperties.SENSORBASE_FULLHOST_KEY;

import org.junit.BeforeClass;

/**
 * Provides a helper class to facilitate JUnit testing.
 *
 * @author Philip Johnson, Pavel Senin.
 */
public class ProjectViewerTestHelper {

  /** The Sensorbase server used in these tests. */
  @SuppressWarnings("unused")
  private static org.hackystat.sensorbase.server.Server sensorbaseServer;
  /** The DailyProjectData server used in these tests. */
  @SuppressWarnings("unused")
  private static org.hackystat.dailyprojectdata.server.Server dpdServer;
  /** The Telemetry server used in these tests. */
  @SuppressWarnings("unused")
  private static org.hackystat.telemetry.service.server.Server tServer;

  /**
   * Constructor.
   */
  public ProjectViewerTestHelper() {
    // Does nothing.
    assert true;
  }

  /**
   * Starts the server going for these tests.
   *
   * @throws Exception If problems occur setting up the server.
   */
  @BeforeClass
  public static void setupServer() throws Exception {
    // Create testing versions of the Sensorbase, DPD, and Telemetry servers.
    sensorbaseServer = org.hackystat.sensorbase.server.Server.newTestInstance();
    dpdServer = org.hackystat.dailyprojectdata.server.Server.newTestInstance();
    tServer = org.hackystat.telemetry.service.server.Server.newTestInstance();
  }

  /**
   * Returns the hostname associated with this Telemetry test server.
   *
   * @return The host name, including the context root.
   */
  protected String getTelemetryHostName() {
    return tServer.getServerProperties().getFullHost();
  }

  /**
   * Returns the sensorbase hostname that this Telemetry server communicates with.
   *
   * @return The host name, including the context root.
   */
  protected static String getSensorBaseHostName() {
    return tServer.getServerProperties().get(SENSORBASE_FULLHOST_KEY);
  }

  /**
   * Returns the sensorbase hostname that this Telemetry server communicates with.
   *
   * @return The host name, including the context root.
   */
  protected String getDailyProjectDataHostName() {
    return tServer.getServerProperties().get(DAILYPROJECTDATA_FULLHOST_KEY);
  }

}
